CREATE TABLE [dbo].[SegmentationJob]
(
[SegmentationJobKey] [uniqueidentifier] NOT NULL,
[MemberObjectType] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SegmentationJob_MemberObjectType] DEFAULT (''),
[SegmentationJobStatusCode] [int] NOT NULL CONSTRAINT [DF_SegmentationJob_SegmentationJobStatusCode] DEFAULT ((0)),
[Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SegmentationJob_Name] DEFAULT (''),
[Description] [nvarchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SegmentationJob_Description] DEFAULT (''),
[InactiveDate] [datetime] NULL,
[SupersetQueryDocumentKey] [uniqueidentifier] NULL,
[UseNSelectFlag] [bit] NOT NULL CONSTRAINT [DF_SegmentationJob_UseNSelectFlag] DEFAULT ((0)),
[NSelectSegments] [int] NOT NULL CONSTRAINT [DF_SegmentationJob_NSelectSegments] DEFAULT ((0)),
[NSelectSegmentElements] [int] NOT NULL CONSTRAINT [DF_SegmentationJob_NSelectSegmentElements] DEFAULT ((0)),
[LastListCreatedByUserKey] [uniqueidentifier] NULL,
[LastListCreatedOn] [datetime] NULL,
[IsExecutionEnabled] [bit] NOT NULL CONSTRAINT [DF_SegmentationJob_IsExecutionEnabled] DEFAULT ((1)),
[UpdatedByUserKey] [uniqueidentifier] NOT NULL,
[UpdatedOn] [datetime] NOT NULL,
[CreatedByUserKey] [uniqueidentifier] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[MarkedForDeleteOn] [datetime] NULL,
[AccessKey] [uniqueidentifier] NOT NULL,
[SystemEntityKey] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SegmentationJob] ADD CONSTRAINT [PK_SegmentationJob] PRIMARY KEY CLUSTERED ([SegmentationJobKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SegmentationJob_AccessKey] ON [dbo].[SegmentationJob] ([AccessKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SegmentationJob_CreatedByUserKey] ON [dbo].[SegmentationJob] ([CreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SegmentationJob_LastListCreatedByUserKey] ON [dbo].[SegmentationJob] ([LastListCreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SegmentationJob_SystemEntityKey] ON [dbo].[SegmentationJob] ([SystemEntityKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SegmentationJob_UpdatedByUserKey] ON [dbo].[SegmentationJob] ([UpdatedByUserKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SegmentationJob] ADD CONSTRAINT [FK_SegmentationJob_AccessMain] FOREIGN KEY ([AccessKey]) REFERENCES [dbo].[AccessMain] ([AccessKey])
GO
ALTER TABLE [dbo].[SegmentationJob] ADD CONSTRAINT [FK_SegmentationJob_SystemEntity] FOREIGN KEY ([SystemEntityKey]) REFERENCES [dbo].[SystemEntity] ([SystemEntityKey])
GO
ALTER TABLE [dbo].[SegmentationJob] ADD CONSTRAINT [FK_SegmentationJob_UniformRegistry] FOREIGN KEY ([SegmentationJobKey]) REFERENCES [dbo].[UniformRegistry] ([UniformKey])
GO
ALTER TABLE [dbo].[SegmentationJob] ADD CONSTRAINT [FK_SegmentationJob_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[SegmentationJob] ADD CONSTRAINT [FK_SegmentationJob_UserMain_LastListCreatedBy] FOREIGN KEY ([LastListCreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[SegmentationJob] ADD CONSTRAINT [FK_SegmentationJob_UserMain_UpdatedBy] FOREIGN KEY ([UpdatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO